package com.scalosoft.action.jquery;

import java.util.Calendar;
import java.util.Date;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;

@Namespace(value="/jquery")
public class Datepicker extends ActionSupport {

	private static final long serialVersionUID = 7641453994518254115L;

	private Date dateValue;
	private Date nameValue;
	private Date minValue;
	private Date maxValue;
	
	@Action(value = "/datepicker", results = { @Result(location = "/jquery/datepicker.jsp", name = "success") })
	public String execute() throws Exception {

		Calendar c = Calendar.getInstance();
		c.roll(Calendar.WEEK_OF_YEAR, -1);

		dateValue = c.getTime();

		c.roll(Calendar.MONTH, -1);

		nameValue = c.getTime();

		c.setTime(new Date());
		c.roll(Calendar.MONTH, -1);
		minValue = c.getTime();

		c.roll(Calendar.MONTH, 2);
		maxValue = c.getTime();
		
		return SUCCESS;
	}

	public Date getDateValue() {
		return dateValue;
	}

	public Date getNameValue() {
		return nameValue;
	}

	public Date getMinValue() {
		return minValue;
	}

	public Date getMaxValue() {
		return maxValue;
	}
}
